package com.example.choupaiapp.main.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.example.choupaiapp.R;
import com.lzy.ninegrid.NineGridView;

/**
 * Created by ASUS on 2019/6/4.
 */

public class GlideNineImageLoader implements NineGridView.ImageLoader {


    @Override
    public void onDisplayImage(Context context, ImageView imageView, String url) {
        if (url.endsWith(".gif")) {
            Glide.with(context)
                    .load(url)
                    .asGif()
                    .thumbnail(0.1f)
                    .dontAnimate()
                    .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                    .placeholder(R.color.black)
                    .error(R.color.black)
                    .into(imageView);
        } else {
            Glide.with(context)
                    .load(url)
                    .thumbnail(0.1f)
                    .dontAnimate()
                    .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                    .placeholder(R.color.black)
                    .error(R.color.black)
                    .into(imageView);
        }
    }

    @Override
    public Bitmap getCacheImage(String url) {
        return null;
    }
}
